Title: Making Weechat's Buflist Look Nicer
Date: 2020-11-08 17:00
Category: Weechat
Tags: CLI, weechat, conf


**NOTE: Added 2021-02-24 update section**


###Buflist
Not too [long ago]... ok, I guess about three and a half years ago now... [WeeChat] got one of its greatest features incorporated into the main code -- the buflist.
Prior to this, it was in the form of a script.

With this change, buflist became more powerful and versatile as well.


####Fancyness
For a while now I've had a fancy bit of logic in my buflist to show when a network is disconnected.
When the topic of having away and part status in the buflist came up while chatting, I did some refactoring to add those as well:


    :::php
    /set buflist.format.buffer "${format_number}${indent}${format_nick_prefix}${color_hotlist}${if:(${buffer.full_name} =~ ^irc)?${if:(${irc_server.away_time} > 0)?${color:yellow}>}${if:(${irc_channel.part} == 1)?${color:magenta}_}${if:(${irc_server.is_connected} == 0)?${color:*magenta}*}}${if:${type}==private?↪}${name}"

    ## A Breakdown
    /set buflist.format.buffer 
    "
        ${format_number}                                ## buflist.format.number
        ${indent}                                       ## buflist.format.indent
        ${format_nick_prefix}                           ## buflist.format.nick_prefix
        ${color_hotlist}
            ${if:(${buffer.full_name} =~ ^irc)?         ## Checks that buffer is from irc plugin
                ${if:(${irc_server.away_time} > 0)?     ## Checks if an away time is set
                    ${color:yellow}>                    ## Adds color and indicator
                }
                ${if:(${irc_channel.part} == 1)?        ## Checks part status
                    ${color:magenta}_                   ## Adds color and indicator
                }
                ${if:(${irc_server.is_connected} == 0)? ## Checks connect status
                    ${color:*magenta}*                  ## Adds color and indicator
                }
            }
            ${if:${type}==private?                      ## Checks if privmsg
                ↪                                       ## Adds indicator
            }
        ${name}                                         ## buflist.format.name
    "


#####Explanation
With this setting, an `/away` irc buffer gets colored yellow and marked with a `>`; a `/part`-ed chan gets colored magenta and marked with a `_`; and a disconnected irc buffer gets bold magenta and marked with a `*`.
The order of the `if` test also means that away < parted < disconnected in regards to color.

![weechat_buflist_formatting screenshot]({static}/pics/weechat_buflist_formatting.png)


####Toning Down
As I use [screen_away.py] script, and as this buflist.format.buffer overrides hostlist msg colorings, I ended up using this minor tweak to only apply the away to the server buffers (which I have separated).

    :::php
    /set buflist.format.buffer "${format_number}${indent}${format_nick_prefix}${color_hotlist}${if:(${buffer.full_name} =~ ^irc)?${if:(${irc_server.away_time} > 0 && ${buffer.name} =~ ^server)?${color:yellow}>}${if:(${irc_channel.part} == 1)?${color:magenta}_}${if:(${irc_server.is_connected} == 0)?${color:*magenta}*}}${if:${type}==private?↪}${name}"


#####Update 2021-02-24: Per buffer filter status
I have added a bit to check if the `/filter`'s have been toggled off for individual windows <sup>(Alt+-)</sup> using `${if:(${irc_channel.filter} == 0)?${color:red}⨯${color_hotlist}}`.
The full setting I use is now:

    :::php
    /set buflist.format.buffer "${format_number}${indent}${if:(${buffer.filter} == 0)?${color:magenta}⨯ }${format_nick_prefix}${color_hotlist}${if:(${buffer.full_name} =~ ^irc)?${if:(${irc_server.away_time} > 0 && ${buffer.name} =~ ^server)?${color:yellow}>}${if:(${irc_channel.part} == 1)?${color:magenta}▒}${if:(${irc_server.is_connected} == 0)?${color:*magenta}█}}${if:${type}==private?↪}${name}"


###Other Settings
I'll go ahead and include my other relevant seeming settings for my buflist setup here as well.


    :::php
    ## copypasta'ed out of /fset
    buflist.format.buffer                   string   "${format_number}${indent}${format_nick_prefix}${color_hotlist}${if:(${buffer.full_name} =~ ^irc)?${if:(${irc_server.away_time} > 0)?${color:yellow}>}${if:(${irc_channel.part} == 1)?${color:magenta}_}${if:(${irc_server.is_connected} == 0)?${color:*magenta}*}}${if:${type}==private?↪}${name}"
    buflist.format.buffer_current           string   "${color:red,17}${format_buffer}"
    buflist.format.hotlist_highlight        string   "${color:red}"
    buflist.format.hotlist_low              string   "${color:white}"
    buflist.format.hotlist_message          string   "${color:blue}"
    buflist.format.hotlist_none             string   "${color:247}${if:${type}==server?${color:240}}"
    buflist.format.hotlist_private          string   "${color:red}"
    buflist.format.indent                   string   "${color:240}${if:${buffer.next_buffer.local_variables.type}=~^(channel|private)$?├ :└─}"
    buflist.format.number                   string   "${color:240}${number}${if:${number_displayed}?.: }"
    buflist.look.nick_prefix                boolean  on
    buflist.look.nick_prefix_empty          boolean  off


The buflist.format.indent is one of the more fancy options, as I like the extra readability.
It should be noted that I have my server buffers split individual, and my buffers hierarchically sorted under each server.
While I used to do this manually, I now use the [autosort.py] script with some fancy logic to deal with it for me <sup>(and disabled mouse buffer rearrangement to reduce hair pulling)</sup>.

Also worth noting is that I disable the hotlist_low priority msgs from my hotlist/buflist, so I never see it... It mostly just covers content that I would [smartfilter] anyway.

###Links
[long ago]  
[WeeChat]  
[screen_away.py]  
[autosort.py]  
[smartfilter]  


[long ago]: https://weechat.org/files/releasenotes/ReleaseNotes-1.8.html
[WeeChat]: https://weechat.org/
[screen_away.py]: https://weechat.org/scripts/source/screen_away.py.html/
[autosort.py]: https://weechat.org/scripts/source/autosort.py.html/
[smartfilter]: https://blog.weechat.org/post/2008/10/25/Smart-IRC-join-part-quit-message-filter
